<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>我的咨询</title>  
    <style type="text/css">
    .list-title-1 {
   		width:100%;
	    height:1.8rem;
	    line-height: 1.8rem;
	    background-color: #152b52;
	    color:white;
	    text-align: center;
	    padding-left: 1rem;
	}
	.menudiv{height:200px;border-left:#cccccc solid 1px;border-right:#cccccc solid 1px;border-top:0;background:#fefefe}
	.menudiv div{padding:15px;line-height:28px;}
	/*星星样式*/
	
    </style>
</head>
<body>
<div  style="text-align:left;">
	<div class="ui segment" style="background-color: #152b52;margin:0rem;font-size:16px;" id="tab1">
	  <div class="ui inverted secondary menu" >
	    <a class="item" id="one1" onclick="setTab('one',1)">全部 </a>
	    <a class="item" id="one2" onclick="setTab('one',2)">待接单 </a>
	    <a class="item" id="one3" onclick="setTab('one',3)">进行中</a>
	    <a class="item" id="one4" onclick="setTab('one',4)">已完成</a>
	    <a class="item" id="one5" onclick="setTab('one',5)">已评价</a>
	  </div>
	</div>
	<div class="menudiv">
	<div class="ui middle aligned divided list"  style="background-color:#fff;margin:0rem;padding:0rem;display:block;"  id="con_one_1">
	<c:choose>
		<c:when test="${allorders == null or fn:length(allorders)==0 }">
			<span style="display: flex; justify-content: center">您暂时没有咨询订单信息</span>
		 	<span style="display: flex; justify-content: center">请前往 顾问菜单-我的开放时间，开放您的可用时间</span>
		</c:when>
		<c:otherwise>
				<c:forEach items="${allorders}" var="order">
  				<div class="position" data-position-id="${order.id}">
					<div class="list">
						<h5 class="list_title">
							${order.orderdesc}
						</h5>
						<c:choose>
							<c:when test="${order.status==0}">
								<button class="ui button active" id="accept" data-position-id="${order.id}" style="float:right;width:25%;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">接单</button>
								<button class="ui button active" id="refuse" data-position-id="${order.id}" style="float:right;width:25%;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">拒单</button>
							</c:when>
							<c:when test="${order.status==1}">
								<button class="ui button active" id="confirm" data-position-id="${order.id}" style="float:right;width:25%;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">确认完成</button>
							</c:when>
							<c:otherwise>
								<button class="ui button active" id="detail" data-position-id="${order.id}" style="float:right;width:25%;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">详情</button>
							</c:otherwise>
						</c:choose>
						
						<p class="list_content content">预约时间：${order.orderTime}</p>
						<p class="list_content content">
							订单号：YQS${order.ordercode}
						</p>
						<p class="list_content content" >订单状态：<span style="color:#F47e2d;font-weight:bold;">${order.statusName}</span></p>
					</div>
	               
				</div>
				 <hr class="hrtext"/>
				</c:forEach>
		</c:otherwise>
	</c:choose>
	</div>	
	<div class="ui middle aligned divided list"  style="background-color:#fff;margin:0rem;padding:0rem;display:none;"  id="con_one_2">
	<c:choose>
		<c:when test="${unorderlist == null or fn:length(unorderlist)==0 }">
			<span style="display: flex; justify-content: center">您暂时没有咨询订单信息</span>
			<span style="display: flex; justify-content: center">请前往 顾问菜单-我的开放时间，开放您的可用时间</span>
		</c:when>
		<c:otherwise>
				<c:forEach items="${unorderlist}" var="order">
  				<div class="position" data-position-id="${order.id}">
					<div class="list">
						<h5 class="list_title">
							${order.orderdesc}
						</h5>
						<button class="ui button active" id="accept" data-position-id="${order.id}" style="float:right;width:25%;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">接单</button>
						<%-- <button class="ui button active" id="detail" data-position-id="${order.id}" style="float:right;width:25%;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">详情</button> --%>
						<p class="list_content content">预约时间：${order.orderTime}</p>
						<button class="ui button active" id="refuse" data-position-id="${order.id}" style="float:right;width:25%;background-color:#1fbad6!important;padding-top:0.7rem;padding-bottom:0.5rem;color:#fff">拒单</button>
						<p class="list_content content">
							订单号：YQS${order.ordercode}
						</p>
						<p class="list_content content" >订单状态：<span style="color:#F47e2d;font-weight:bold;">${order.statusName}</span></p>
					</div>
	               
				</div>
				 <hr class="hrtext"/>
				</c:forEach>
		</c:otherwise>
	</c:choose>
	</div>
	
	<div class="ui middle aligned divided list"  style="background-color:#fff;margin:0rem;display:none;"  id="con_one_3">
	<c:choose>
		<c:when test="${orderinglist == null or fn:length(orderinglist)==0 }">
			<span style="display: flex; justify-content: center">您暂时没有咨询订单信息</span>
			<span style="display: flex; justify-content: center">请前往 顾问菜单-我的开放时间，开放您的可用时间</span>
		</c:when>
		<c:otherwise>
				<c:forEach items="${orderinglist}" var="order">
  				<div class="position" data-position-id="${order.id}">
					<div class="list">
						<h5 class="list_title">
							${order.orderdesc}
						</h5>
						<p class="list_content content">预约时间：${order.orderTime}</p>
						<p class="list_content content">
							订单号：YQS${order.ordercode}
						</p>
						<p class="list_content content" >订单状态：<span style="color:#F47e2d;font-weight:bold;">${order.statusName}</span></p>
					</div>
	               
				</div>
				 <hr class="hrtext"/>
				</c:forEach>
		</c:otherwise>
	</c:choose>
	</div>
	
	<div class="ui middle aligned divided list"   style="background-color:#fff;margin:0rem;display:none;"  id="con_one_4">
	<c:choose>
		<c:when test="${orderedlist == null or fn:length(orderedlist)==0 }">
			<span style="display: flex; justify-content: center">您暂时没有咨询订单信息</span>
			<span style="display: flex; justify-content: center">请前往 顾问菜单-我的开放时间，开放您的可用时间</span>
		</c:when>
		<c:otherwise>
				<c:forEach items="${orderedlist}" var="order">
  				<div class="position" data-position-id="${order.id}">
					<div class="list">
						<h5 class="list_title">
							${order.orderdesc}
						</h5>
						<p class="list_content content">预约时间：${order.orderTime}</p>
						<p class="list_content content">
							订单号：YQS${order.ordercode}
						</p>
						<p class="list_content content" >订单状态：<span style="color:#F47e2d;font-weight:bold;">${order.statusName}</span></p>
					</div>
	               
				</div>
				 <hr class="hrtext"/>
				</c:forEach>
		</c:otherwise>
	</c:choose>
	</div>
	
	<div class="ui middle aligned divided list"  style="background-color:#fff;margin:0rem;display:none;"  id="con_one_5">
	<c:choose>
		<c:when test="${evalist == null or fn:length(evalist)==0 }">
			<span style="display: flex; justify-content: center">您暂时没有咨询订单信息</span>
			<span style="display: flex; justify-content: center">请前往 顾问菜单-我的开放时间，开放您的可用时间</span>
		</c:when>
		<c:otherwise>
				<c:forEach items="${evalist}" var="eva">
  				<div class="position" data-position-id="${eva.id}">
					<div class="list">
						<h5 class="list_title">
							${eva.buyerName}<span style="color:#F47e2d;float:right;">对您的评分：${eva.buyerEvalScore }分
						</span>
						</h5>
						<p class="list_content content">${eva.buyerEvalContent }</p>
						<p class="list_content content" >咨询项目：${eva.orderdescIds}</p>
						<p class="list_content content">
							订单号：YQS${eva.orderCode}
						</p> 
					</div>
	               
				</div>
				 <hr class="hrtext"/>
				</c:forEach>
		</c:otherwise>
	</c:choose>
	</div>
		<!--  <hr class="hrtext"/> -->
	</div>
</div>



<script src="${ctx}/resources/jweixin-1.0.0.js"></script>
<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">
function setTab(name,cursel){
	 cursel_0=cursel;
	 for(var i=1; i<=links_len; i++){
	  var menu = document.getElementById(name+i);
	  var menudiv = document.getElementById("con_"+name+"_"+i);
	  if(i==cursel){
	   menudiv.style.display="block";
	  }
	  else{
	   menudiv.style.display="none";
	  }
	 }
	}
	function Next(){
	 cursel_0++;
	 if (cursel_0>links_len)cursel_0=1
	 setTab(name_0,cursel_0);
	}
	var name_0='one';
	var cursel_0=1;
	var ScrollTime=300000000;//循环周期（毫秒）
	var links_len,iIntervalId;
	onload=function(){
	 var links = document.getElementById("tab1").getElementsByTagName('a')
	 links_len=links.length;
	 for(var i=0; i<links_len; i++){
	  links[i].onmouseover=function(){
	   clearInterval(iIntervalId);
	   this.onmouseout=function(){
	    iIntervalId = setInterval(Next,ScrollTime);;
	   }
	  }
	 }
	 document.getElementById("con_"+name_0+"_"+links_len).parentNode.onmouseover=function(){
	  clearInterval(iIntervalId);
	  this.onmouseout=function(){
	   iIntervalId = setInterval(Next,ScrollTime);;
	  }
	 }
	 setTab(name_0,cursel_0);
	 iIntervalId = setInterval(Next,ScrollTime);
	}
</script>
<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'showOptionMenu']  
});

$('#detail').on('click', function() {
    var positionid = $(this).attr('data-position-id');
    var getUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+positionid;
    window.location.href = getUrl;
});    

var handler = { 
        activate: function() { 
            $(this).addClass('active').siblings().removeClass('active'); 

            if($(this).attr('id') == 'accept') {
              var orderId  = $(this).attr('data-position-id');
              console.log(orderId);
              var postUrl = '${ctx}/wechat/hunter/updOrder.do';
              $.ajax({ 
                  url: postUrl, 
                  type: "POST", 
                  data: {orderId:orderId,status:1},
                  success: function(data, status){
                      if (data.errorcode == 0){
                    	  alert(data.msg);
                          var forwardUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+ orderId;
                          window.location.href = forwardUrl;
                      }else{
                          alert(data.msg);
                          $(this).removeClass('disabled');
                      }
                  }, 
                  error: function(){ 
                      alert("服务出错，请稍后尝试"); 
                      $(this).removeClass('disabled');
                  } 
              });
            }
            if($(this).attr('id') == 'refuse') {
                var orderId  =$(this).attr('data-position-id');
                console.log(orderId);
                var postUrl = '${ctx}/wechat/hunter/updOrder.do';
                $.ajax({ 
                    url: postUrl, 
                    type: "POST", 
                    data: {orderId:orderId,status:5},
                    success: function(data, status){
                        if (data.errorcode == 0){
                      	  	alert(data.msg);
                            var forwardUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+ orderId;
                            window.location.href = forwardUrl;
                        }else{
                            alert(data.msg);
                            $(this).removeClass('disabled');
                        }
                    }, 
                    error: function(){ 
                        alert("服务出错，请稍后尝试"); 
                        $(this).removeClass('disabled');
                    } 
                });
         	 }
   
            if($(this).attr('id') == 'confirm') {
                var orderId  =$(this).attr('data-position-id');
                console.log(orderId);
                var postUrl = '${ctx}/wechat/hunter/updOrder.do';
                $.ajax({ 
                    url: postUrl, 
                    type: "POST", 
                    data: {orderId:orderId,status:7},
                    success: function(data, status){
                        if (data.errorcode == 0){
                      	  	alert(data.msg);
                            var forwardUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+ orderId;
                            window.location.href = forwardUrl;
                        }else{
                            alert(data.msg);
                            $(this).removeClass('disabled');
                        }
                    }, 
                    error: function(){ 
                        alert("服务出错，请稍后尝试"); 
                        $(this).removeClass('disabled');
                    } 
                });
         	 }
            if($(this).attr('id') == 'detail') {
            	 var positionid = $(this).attr('data-position-id');
            	 console.log("orderId="+positionid);
                 var getUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+positionid;
                 window.location.href = getUrl;
         	 }
            
            
            
        } 
    };

    $(document).ready(function() { 
    	 //=实时显示分数.【index】搜索匹配的元素，并返回相应元素的索引值，从0开始计数。
   	   $("#div li").mouseover(function () {
   	   $("#p").html(parseInt( $(this).index("#div li"))+1); });         
   	   $('.button').on('click', handler.activate);
	   	$('.position').click(function(){
	   	 var positionid = $(this).attr('data-position-id');
	   	 console.log("orderId="+positionid);
	        var getUrl = '${ctx}/wechat/hunter/toOrderDetail.do?orderId='+positionid;
	        window.location.href = getUrl;
	   });
    });
</script>

</body>
</html>